package com.qianguo.buyer.entity;

import com.eva.androidlibrary.api.entity.BaseBean;

import java.util.ArrayList;
import java.util.List;

/**
 * @author eva
 * @date 16/5/25
 */
public class KeyValuePairs extends BaseBean {

    protected List<KeyValuePair> keyValuePairs = new ArrayList<>();

    public void add(KeyValuePair item) {
        keyValuePairs.add(item);
    }

    public int size() {
        return keyValuePairs == null ? 0 : keyValuePairs.size();
    }

    public String getKey(int position) {
        if (keyValuePairs.size() > position) {
            return keyValuePairs.get(position).getKey();
        }
        return "";
    }

    public String getValue(int position) {
        if (keyValuePairs.size() > position) {
            return keyValuePairs.get(position).getValue();
        }
        return "";
    }

    public List<String> getValues() {
        List<String> values = new ArrayList<>();
        for (KeyValuePair item : keyValuePairs) {
            values.add(item.getValue());
        }
        return values;
    }

    public KeyValuePair getItem(int position) {
        if (keyValuePairs.size() > position) {
            return keyValuePairs.get(position);
        }
        return null;
    }
}
